package com.chinaunicom.create.factory.simplefactory;

import com.chinaunicom.create.factory.APizza;
import com.chinaunicom.create.factory.BPizza;
import com.chinaunicom.create.factory.CPizza;
import com.chinaunicom.create.factory.Pizza;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2022/7/15 10:58
 * Description: 简单工厂
 */
public class PizzaFactory {
    private String type;

    public PizzaFactory(String type) {
        this.type = type;
    }


    public Pizza createPizza() {
        Pizza pizza = null;
        switch (type) {
            case "A":
                pizza = new APizza();
                break;
            case "B":
                pizza = new BPizza();
                break;
            case "C":
                pizza = new CPizza();
                break;
        }

        return pizza;
    }

}
